package cn.edu.szpt.qqdemov3.util;

import android.content.Context;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

public class MyVolleySingleton {

    private static MyVolleySingleton instance;
    private final Context context;

    private RequestQueue queue;


    private MyVolleySingleton(Context context) {

        this.context = context;
    }


    public static MyVolleySingleton getInstance(Context context) {
        if (instance == null) {
            instance = new MyVolleySingleton(context);
        }

        return instance;
    }

    public RequestQueue getQueue() {
        if (queue == null) {
            queue = Volley.newRequestQueue(context.getApplicationContext());
        }
        return queue;
    }

    public void addQueue(Request request){
        queue.add(request);
    }


}
